import {createApp} from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import ElementPlus from 'element-plus';
// import locale from 'element-plus/lib/locale/lang/zh-cn';
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
// import 'element-plus/lib/theme-chalk/index.css';
import './style/index.scss';


import eventBus from 'vue3-eventbus';


const app = createApp(App);


app.directive('jurisdiction', {
		mounted(el: HTMLElement, binding) {
			let func = () => {
		
				let result = store.state.jurisdiction
				
				// console.log( '是否匹配',result.includes(binding.value))
				if(!(result as string[]).includes(binding.value)) {
					el.classList.add('hide');
				} else {
					el.classList.remove('hide');
				}
				
			};
		
			func();
			
			eventBus.on('jurisdiction:update', func);
		}
})

app.use(eventBus)
app.use(ElementPlus, {locale: zhCn})
app.use(store).use(router).mount('#app')





//全局方法
// app.config.globalProperties.$http = (d: any) => {
// 	console.log("123456789", d)
// }

//动态添加的全局组件。
const modules = import.meta.globEager("./components/widget/*.vue");

Object.keys(modules).forEach((it: any) => {
	// console.debug("it.type",modules[it]);
	app.component(modules[it].default.name,  modules[it].default || modules[it]);
});
